package httpclient

import (
	"context"
	"net/url"
	"time"
)

type requestOptions struct {
	query   url.Values
	body    interface{}
	headers map[string]string
	timeout time.Duration
	ctx     context.Context
}
type RequestOption func(*requestOptions)

func WithQuery(query url.Values) RequestOption {
	return func(o *requestOptions) {
		o.query = query
	}
}

func WithBody(body interface{}) RequestOption {
	return func(o *requestOptions) {
		o.body = body
	}
}

func WithHeader(key, value string) RequestOption {
	return func(o *requestOptions) {
		if o.headers == nil {
			o.headers = make(map[string]string)
		}
		o.headers[key] = value
	}
}

func WithTimeout(timeout time.Duration) RequestOption {
	return func(o *requestOptions) {
		o.timeout = timeout
	}
}
func WithContext(ctx context.Context) RequestOption {
	return func(o *requestOptions) {
		o.ctx = ctx
	}
}
